Auto merge of #5217 - matklad:known-crate-types, r=alexcrichton
authorbors <bors@rust-lang.org>
Thu, 22 Mar 2018 14:07:49 +0000 (14:07 +0000)
committerbors <bors@rust-lang.org>
Thu, 22 Mar 2018 14:07:49 +0000 (14:07 +0000)
commitbc83efe3237bd3b1b01165d61ca0a16f7d94ded2
treef110a7c2bfaf7c8cfc5599d224faa10665734327
parent028e474e28e23438dcffcc88ff501371379874f6
parent9f7618b36c07e91f10ce643fc6538a289f3c8935
Auto merge of #5217 - matklad:known-crate-types, r=alexcrichton

Preprobe info for known crate type

Previously, we've calculated the set of crate types to learn about by
recursively walking the graph of units. However, to actually know
dependencies of a unit exactly, we must know target specific info, and
we don't know it at this moment (in fact, we are trying calculating it).

Note that crate-type calculation is already lazy, we don't have to calc
all crate-types upfront. So, let's just scrape this info once for
well-known crate types, and fill whatever is left lazily.

@alexcrichton would this approach work at all? I think it would, if `KNOWN_CRATE_TYPES` are all available for all target-tripples we support. Is it a valid assumption?

The larger picture is that I am trying to make unit dependency resolution eager and move it into the separate file. I even got something working, but I have to run dependency resolution three times, because it is not exactly idempotent for various reasons, including this target-info stuff :)

```
    cx.prepare()?;
    cx.build_unit_map(units.clone())?; // resolve dependencies
    cx.probe_target_info(&units)?;
    cx.build_unit_map(units.clone())?; // resolve again
    cx.build_used_in_plugin_map(&units)?;
    custom_build::build_map(&mut cx, &units)?;
    cx.build_unit_map(units.clone())?; // and resolve one final time :)
```
src/cargo/ops/cargo_clean.rs